using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using UnityEngine;

public class NewBehaviourScript1 : MonoBehaviour
{
    string x;
    string y;
    string op;
    bool m_flag;
    double result;
    // Start is called before the first frame update
    void Start()
    {
        x="";
        y="";
        op="";
        m_flag = true;
        result = 0;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 100, 20, 20), "0"))
        {
            if (m_flag) { x = x + "0"; } else{y = y + "0";}
        }
        if (GUI.Button(new Rect(10, 10, 20, 20), "1"))
        {
            if (m_flag) { x = x + "1"; } else { y = y + "1"; }
        }
        if(GUI.Button(new Rect(40, 10, 20, 20), "2"))
        {
             if (m_flag) { x = x + "2"; } else { y = y + "2"; }
        }
        if (GUI.Button(new Rect(70, 10, 20, 20), "3")) {
            if (m_flag) { x = x + "3"; } else { y = y + "3"; }
        }
        if (GUI.Button(new Rect(10, 40, 20, 20), "4")) {
            if (m_flag) { x = x + "4"; } else { y = y + "4"; }
        }
        if (GUI.Button(new Rect(40, 40, 20, 20), "5")) {
            if (m_flag) { x = x + "5"; } else { y = y + "5"; }
        }
        if (GUI.Button(new Rect(70, 40, 20, 20), "6")) {
            if (m_flag) { x = x + "6"; } else { y = y + "6"; }
        }
        if (GUI.Button(new Rect(10, 70, 20, 20), "7")) {
            if (m_flag) { x = x + "7"; } else { y = y + "7"; }
        }
        if (GUI.Button(new Rect(40, 70, 20, 20), "8")) {
            if (m_flag) { x = x + "8"; } else { y = y + "8"; }
        }
        if (GUI.Button(new Rect(70, 70, 20, 20), "9")) {
            if (m_flag) { x = x + "9"; } else { y = y + "9"; }
        }


        if (GUI.Button(new Rect(110, 10, 20, 20), "+")) { op ="+";m_flag = false;}
        if (GUI.Button(new Rect(110, 40, 20, 20), "-")) { op ="-";m_flag = false; }
        if (GUI.Button(new Rect(140, 10, 20, 20), "*")) { op ="*";m_flag = false;}
        if (GUI.Button(new Rect(140, 40, 20, 20), "/")) { op ="/";m_flag = false; }
        if (GUI.Button(new Rect(110, 70, 20, 20), "=")) { m_flag = true;
            double a = double.Parse(x);
            double b = double.Parse(y);
            if(op == "+"){result = a+b;}else
            if(op == "-"){result = a-b;}else
            if(op == "*"){result = a*b;}else
            if(op == "/"){result = a/b;}


         x = y =op = ""; }

        GUI.TextField(new Rect(170, 10, 100, 30),x);
        GUI.TextField(new Rect(170, 50, 100, 30),op);
        GUI.TextField(new Rect(170, 90, 100, 30),y);
        GUI.TextField(new Rect(170, 130, 100, 30),"=");
        GUI.TextField(new Rect(170, 170, 100, 30),result.ToString());
    }

}
